/**********************************************************/
/* Goblin Defense - A tower defense game for Wii Homebrew */
/* Copyright (C) 2009 Ricardo Bueno Cordeiro              */
/* Licensed under de GNU General Public License v2.0      */
/*   See license_gplv2.txt for detalis                    */
/**********************************************************/

#ifndef __SOUND_OGG_LOADER_H_
#define __SOUND_OGG_LOADER_H_

#include <gccore.h>

#include "vorbis/codec.h"
#include "vorbis/vorbisfile.h"

#include "sound.h"

class SoundOggLoader : public SoundLoader {
	private:
	const u8 *file;
	u32 file_size;
	size_t current_pos;

	static size_t read_func(void *ptr, size_t size, size_t nmemb, void *datasource);
	static int seek_func(void *datasource, ogg_int64_t offset, int whence);
	static long tell_func(void *datasource);
	static ov_callbacks memory_access_callbacks;

	u16 num_bits_per_sample;
	u16 num_channel;
	s32 pitch;

	OggVorbis_File vf;

	public:
	SoundOggLoader(const u8 *f, u32 s);
	~SoundOggLoader();
	
	u32 get_size();
	s32 get_pitch();
	u16 get_num_bits_per_sample();
	u16 get_num_channel();
	void get_samples(void *buffer, u32 start, u32 size);
};

#endif
